function jsonp ({ url, params, callback }) {
  return new Promise((resolve, reject) => {
    let script = document.createElement('script')
    window[callback] = function (data) {
      resolve(data)
      this.document.body.removeChild(script)
      // delete window.callback
    }
    params = {...params, callback}
    let arr = []
    for (let key in params) {
      arr.push(`${ key }=${ params[key] }`)
    }
    script.src = `${ url }?${ arr.join('&') }`
    document.body.appendChild(script)
  })
}

// 需要服务端支持
const express = require('express')
const app = express()
app.get('/xxx', function (req, res) {
  let { words, callback } = req.query
  console.log(words)  // I miss you
  res.end(`${ callback }('Yep')`)
})
app.listen(3000)

// 调用
jsonp({
  url: 'http://localhost:3000/xxx',
  params: { words: 'I miss you' },
  callback: 'show'
}).then(data => {
  console.log(data)
})
